/**
 * @Author：ming
 * @Date：2023/10/27 11:49 PM
 * @Filename：Hot75
 */

/**
 * @author ming
 */
public class Hot75 {
    public void sortColors(int[] nums) {
        int count_0 = 0;
        int count_1 = 0;
        for (int i = 0; i < nums.length; i++) {
            if(nums[i]==0){
                count_0++;
            }else if(nums[i]==1){
                count_1++;
            }
        }

        for (int i = 0; i < nums.length; i++) {
            if(count_0>0){
                nums[i]=0;
                count_0--;
            }else if(count_1>0){
                nums[i]=1;
                count_1--;
            }else {
                nums[i]=2;
            }
        }
    }
}
